package com.example.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.datlichkham.Datlichhen;
import com.example.datlichkham.R;
import com.example.dto.Bacsi;

import java.util.ArrayList;
public class BacSiAdapter extends ArrayAdapter<Bacsi>{
    LayoutInflater inflater;
    Activity activity;
    Bacsi bacsi;
    ArrayList<Bacsi> arrData;
    public BacSiAdapter(Datlichhen activity, int textViewResourceId,
                           ArrayList<Bacsi> objects) {
        super(activity, textViewResourceId, objects);
        arrData = objects;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getDropDownView(int position, View convertView,
                                ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    public View getCustomView(int position, View convertView, ViewGroup parent) {
        View row = inflater.inflate(R.layout.bacsi_rows, parent, false);
        bacsi = null;
        bacsi = (Bacsi) arrData.get(position);
        TextView label=(TextView)row.findViewById(R.id.txtBsRow);
        label.setText(bacsi.tenBacsi);

//        ImageView icon=(ImageView)row.findViewById(R.id.icon);



        return row;
    }
}
